package com.wutuo.roster.provider.dao;

import cn.apestar.core.base.GenericMapper;
import cn.apestar.core.base.MapperAnnotation;
import com.wutuo.roster.provider.domain.ChildApply;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.type.JdbcType;

/**
 * 孩子申请 Dao 层
 *
 * @author lvh
 * @version 1.0
 */

@MapperAnnotation public interface BaseChildApplyMapper extends GenericMapper<ChildApply, Long> {

    @Override @Delete({"delete from child_apply", "where id = #{id,jdbcType=BIGINT}"})
    int deleteByPrimaryKey(Long id);

    @Override @Insert({"insert into child_apply (", "user_id,", "cm_institution_id,", "create_by,",
        "create_date,", "update_by,", "update_date,", "remarks,", "del_flag,", "name,", "photo,",
        "sex,", "tg_type,", "grade,", "year,", "user_type,", "state", " )values(",
        "#{userId,jdbcType=VARCHAR},", "#{cmInstitutionId,jdbcType=VARCHAR},",
        "#{createBy,jdbcType=VARCHAR},", "#{createDate,jdbcType=VARCHAR},",
        "#{updateBy,jdbcType=VARCHAR},", "#{updateDate,jdbcType=VARCHAR},",
        "#{remarks,jdbcType=VARCHAR},", "#{delFlag,jdbcType=VARCHAR},", "#{name,jdbcType=VARCHAR},",
        "#{photo,jdbcType=VARCHAR},", "#{sex,jdbcType=VARCHAR},", "#{tgType,jdbcType=VARCHAR},",
        "#{grade,jdbcType=VARCHAR},", "#{year,jdbcType=VARCHAR},", "#{userType,jdbcType=VARCHAR},",
        "#{state,jdbcType=VARCHAR})"}) int insert(ChildApply record);

    @InsertProvider(type = BaseChildApplySqlProvider.class, method = "insertSelective")
    int insertSelective(ChildApply record);

    @Override
    @Select({"select", "user_id,", "user_type,", "cm_institution_id,", "create_by,", "create_date,",
        "update_by,", "update_date,", "remarks,", "del_flag,", "name,", "photo,", "sex,",
        "tg_type,", "grade,", "year,", "state", "from child_apply",
        "where id = #{id,jdbcType=BIGINT}"})
    @Results({@Result(column = "id", property = "id", jdbcType = JdbcType.VARCHAR, id = true),
        @Result(column = "user_id", property = "userId", jdbcType = JdbcType.VARCHAR),
        @Result(column = "cm_institution_id", property = "cmInstitutionId", jdbcType = JdbcType.VARCHAR),
        @Result(column = "create_by", property = "createBy", jdbcType = JdbcType.VARCHAR),
        @Result(column = "create_date", property = "createDate", jdbcType = JdbcType.VARCHAR),
        @Result(column = "update_by", property = "updateBy", jdbcType = JdbcType.VARCHAR),
        @Result(column = "update_date", property = "updateDate", jdbcType = JdbcType.VARCHAR),
        @Result(column = "remarks", property = "remarks", jdbcType = JdbcType.VARCHAR),
        @Result(column = "del_flag", property = "delFlag", jdbcType = JdbcType.VARCHAR),
        @Result(column = "name", property = "name", jdbcType = JdbcType.VARCHAR),
        @Result(column = "photo", property = "photo", jdbcType = JdbcType.VARCHAR),
        @Result(column = "sex", property = "sex", jdbcType = JdbcType.VARCHAR),
        @Result(column = "tg_type", property = "tgType", jdbcType = JdbcType.VARCHAR),
        @Result(column = "grade", property = "grade", jdbcType = JdbcType.VARCHAR),
        @Result(column = "year", property = "year", jdbcType = JdbcType.VARCHAR),
        @Result(column = "userType", property = "user_type", jdbcType = JdbcType.VARCHAR),
        @Result(column = "state", property = "state", jdbcType = JdbcType.VARCHAR)})
    ChildApply selectByPrimaryKey(Long id);

    @Override
    @UpdateProvider(type = BaseChildApplySqlProvider.class, method = "updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(ChildApply record);

    @Override @Update({"update child_apply", "set ", "user_id = #{userId,jdbcType=VARCHAR},",
        "cm_institution_id = #{cmInstitutionId,jdbcType=VARCHAR},",
        "create_by = #{createBy,jdbcType=VARCHAR},",
        "create_date = #{createDate,jdbcType=VARCHAR},",
        "update_by = #{updateBy,jdbcType=VARCHAR},",
        "update_date = #{updateDate,jdbcType=VARCHAR},", "remarks = #{remarks,jdbcType=VARCHAR},",
        "del_flag = #{delFlag,jdbcType=VARCHAR},", "name = #{name,jdbcType=VARCHAR},",
        "photo = #{photo,jdbcType=VARCHAR},", "sex = #{sex,jdbcType=VARCHAR},",
        "tg_type = #{tgType,jdbcType=VARCHAR},", "grade = #{grade,jdbcType=VARCHAR},",
        "year = #{year,jdbcType=VARCHAR},", "state = #{state,jdbcType=VARCHAR}",
        "where id = #{id,jdbcType=BIGINT}"}) int updateByPrimaryKey(ChildApply record);
}